package com.example.Sao.Tools;

import android.app.Activity;

import java.util.LinkedList;

public class ActivityManagerUtil {
    private static LinkedList<Activity> activities=new LinkedList<>();
    public static void addActivity(Activity activity)
    {
        activities.add(activity);
    }
    public static void removeActivity(Activity activity){
        activities.remove(activity);
    }
    public static void finishAll(){
        for (Activity activity:activities
        ) {
            if(!activity.isFinishing()){
                activity.finish();
            }
        }
    }
    public static void finishOthers(){
        int length=activities.size();
        for(int i=0;i<length-1;i++){
            if(!activities.get(i).isFinishing()){
                activities.get(i).finish();
            }
        }
    }
}
